<template>
  <div class="alarmConfiguration zy-content">
    <!-- 工装与设备 -->
    <search :columns="searchData" @getSearch="getSearch(arguments)"></search>
    <div class="alarmConfiguration">

      <div class="list-layout mt16">
        <!-- 表格 -->
        <div class="btns clear">
          <span class="title">{{ $t("common.listInformation") }}</span>
        </div>
        <div class="tableContent">
          <Table class="resizable-table" border @on-column-width-resize="onColumnWidthResize" :columns="columnsList"
            ellipsis ref="selection" stripe :data="dataArr" @on-selection-change="onSelectChange">
            <template slot-scope="{ row }" slot="moldCode">
                <span class="operationBtn" style="color: #3271f0" @click="showDetail(row)">{{ row.moldCode }}</span>
              </template>
            <template slot-scope="{ row }" slot="action">
              <span class="operationBtn" @click="getDeviceList(row)">关联设备</span>
            </template>
          </Table>
        </div>
        <!-- 分页 -->
        <div class="pageWrap mt16">
          <pageLeftTitle :total="total" :selected="delIds.length" />
          <Page :total="total" :page-size="pageSize" :page-size-opts="pageSizeOption" :current="pageNum"
            @on-change="changePageNum" @on-page-size-change="changePageSize" show-sizer show-total />
        </div>
      </div>
    </div>
    <Modal :mask-closable="false" v-model="create" title="关联设备" class="modal-content-layout" width="70%">
      <search :columns="searchData1" @getSearch="getSearch1(arguments)" :span="6" ref="search1"></search>
      <div class="btns clear btn-box">
        <Button @click="getNoList()">选择设备</Button>
        <Button @click="delRowBetch" v-has="'moldLedgerBatchDelBtn'">
          {{
            $t("common.batchDelete")
          }}
        </Button>
      </div>
      <div class="alarmConfiguration">
        <div class="list-layout">
          <!-- 表格 -->
          <div class="tableContent mt14">
            <Table class="resizable-table" border :columns="columns1" ellipsis ref="selection" stripe :data="dataArr1"
              @on-selection-change="onSelectChange1">
              <template slot-scope="{ row }" slot="action">
                <span class="operationBtn" @click="delRow(row)">
                  <i class="iconfont zy-common-shanchu"></i>
                  {{ $t("common.Delete") }}
                </span>
              </template>
            </Table>
          </div>
          <!-- 分页 -->
          <div class="pageWrap mt16">
            <pageLeftTitle :total="total1" :selected="delIds1.length" />
            <Page :total="total1" :page-size="pageSize1" :page-size-opts="pageSizeOption" :current="pageNum1"
              @on-change="changePageNum1" @on-page-size-change="changePageSize1" show-sizer show-total />
          </div>
        </div>
      </div>
    </Modal>
    <Modal :mask-closable="false" v-model="createLink" title="关联设备" class="modal-content-layout" width="55%">
      <search :columns="searchData1" @getSearch="getSearch2(arguments)" ref="search2" :span="8"></search>
      <div class="alarmConfiguration">
        <div class="list-layout2">
          <!-- 表格 -->
          <div class="tableContent mt14">
            <!-- {{ dataArr2 }}{{ delIds2 }} -->
            <Table class="resizable-table" border @on-column-width-resize="onColumnWidthResize" :columns="columns2"
              ellipsis ref="selection" stripe :data="dataArr2" @on-selection-change="onSelectChange2"></Table>
          </div>
          <!-- 分页 -->
          <div class="pageWrap mt16">
            <pageLeftTitle :total="total2" :selected="delIds2.length" />
            <Page :total="total2" :page-size="pageSize2" :page-size-opts="pageSizeOption" :current="pageNum2"
              @on-change="changePageNum2" @on-page-size-change="changePageSize2" show-sizer show-total />
          </div>
        </div>
      </div>
      <div slot="footer">
        <Button type="default" @click="createLink = false">
          {{
            $t("common.Cancle")
          }}
        </Button>
        <Button type="primary" :loading="loading" @click="linkEq">关联设备</Button>
      </div>
    </Modal>
    <!-- 请确认是否删除弹框 -->
    <Modal :mask-closable="false" v-model="delFaultCodeShowF" :title="$t('common.Delete')" class="modal-title-layout">
      <div class="icon red">
        <i class="iconfont zy-common-shanchu"></i>
      </div>
      <p class="title">
        <span>{{ $t("common.confirmDelete") }}</span>
      </p>
      <div slot="footer">
        <Button type="default" @click="delFaultCodeShowF = false">
          {{
            $t("common.Cancle")
          }}
        </Button>
        <Button type="primary" :loading="loading" @click="deleteOk">
          {{
            $t("maintenance.Confirmed")
          }}
        </Button>
      </div>
    </Modal>
    <Modal :mask-closable="false" v-model="bomDetail" title="工装BOM详情" class="modal-content-layout" width="70%">
      <div class="alarmConfiguration">
        <div class="list-layout2">
          <div class="tableContent mt14">
            <Table class="resizable-table" border @on-column-width-resize="onColumnWidthResize" :columns="columns3"
              ellipsis ref="selection" stripe :data="dataArr3">
            </Table>
          </div>
          <!-- 分页 -->
          <div class="pageWrap mt16">
            <pageLeftTitle :total="total3"  />
            <Page :total="total3" :page-size="pageSize3" :page-size-opts="pageSizeOption" :current="pageNum3"
              @on-change="changePageNum3" @on-page-size-change="changePageSize3" show-sizer show-total />
          </div>
        </div>
      </div>
    </Modal>
  </div>
</template>
<script>
import {
  searchApi,
  getLinkList,
  getDeviceNoList,
  deleteApi,
  devicesAssociated,
  mdDetail
} from "@/api/moldManagement/mdLink.js";
import search from "@/components/curd/searchList.vue";
import toggleTableOperation from "@/mixins/toggleTableOperation";
export default {
  name: "mdLink", //仓库配置
  components: { search },
  mixins: [toggleTableOperation],
  data() {
    return {
      test: [],
      //一级搜索
      searchData: [
        {
          title: "工装BOM名称",
          key: "moldName",

        },
        {
          title: "工装BOM编号",
          key: "moldCode"
        },
        {
          title: "工装BOM版本号",
          key: "bomVersion"
        },
        {
          title: "功能位置",
          key: "functionalLocationString",
          type: "cascader",
          dicUrl: "/basic/organization/findListByToken?level=0",
          params: {
            label: "name",
            value: "code",
            children: "children"
          }
        },
        // {
        //   title: "是否关联设备",
        //   key: "devicesNumber",
        //   type: "select",
        //   dicData: [
        //     {
        //       label: "未关联",
        //       value: "0"
        //     },
        //     {
        //       label: "已关联",
        //       value: "1"
        //     }
        //   ]
        // },
        // {
        //   title: "工装等级",
        //   key: "moldGrade",
        //   type: "select",
        //   dicData: [
        //     {
        //       label: "A",
        //       value: "A"
        //     },
        //     {
        //       label: "B",
        //       value: "B"
        //     },
        //     {
        //       label: "C",
        //       value: "C"
        //     }
        //   ]
        // }
      ],
      searchData1: [
      {
          title: "功能位置",
          key: "functionalLocationString",
          type: "cascader",
          dicUrl: "/basic/organization/findListByToken?level=0",
          params: {
            label: "name",
            value: "code",
            children: "children"
          }
        },
        {
          title: "设备编号",
          key: "deviceNo"
        }
      ],
      //一级table配置
      columns: [
        {
          key: "selection",
          type: "selection",
          width: 60,
          align: "center"
        },
        {
          title: '序号',
          width: 80,
          align: 'center',
          render: (h, params) => {
            return h('span', params.index + (this.pageNum - 1) * this.pageSize + 1);
          },
        },
        {
          title: "工装BOM编号",
          key: "moldCode",
          minWidth: 150,
          align: "center",
          slot: 'moldCode',
        },
        {
          title: "工装BOM名称",
          key: "moldName",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装BOM版本号",
          key: "bomVersion",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "件数",
          key: "equipCount",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "功能位置",
          key: "functionalLocationString",
          minWidth: 200,
          align: "center",
          resizable: true,
          tooltip: true
        },
        // {
        //   title: "工装类型",
        //   key: "moldModel",
        //   minWidth: 100,
        //   align: "center",
        //   resizable: true,
        //   tooltip: true
        // },
        // {
        //   title: "工装等级",
        //   key: "moldGrade",
        //   minWidth: 100,
        //   align: "center",
        //   resizable: true,
        //   tooltip: true
        // },
        // {
        //   title: "评分",
        //   key: "score",
        //   minWidth: 100,
        //   align: "center",
        //   resizable: true,
        //   tooltip: true
        // },
        {
          title: "备注",
          key: "remarks",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "创建人",
          key: "createName",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "创建时间",
          key: "createTime",
          minWidth: 180,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "关联设备数量",
          key: "deviceCount",
          minWidth: 130,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "操作时间",
          key: "operationDeviceTime",
          minWidth: 180,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "操作人",
          key: "operationDeviceName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "操作",
          slot: "action",
          fixed: "right",
          minWidth: 180,
          align: "center"
        }
      ],
      columns1: [
        {
          key: "selection",
          type: "selection",
          width: 60,
          align: "center"
        },
        // {
        //   title: "优先级",
        //   key: "priority",
        //   minWidth: 100,
        //   align: "center",
        //   resizable: true,
        //   tooltip: true
        // },
        {
          title: "设备名称",
          key: "deviceName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "资产编号",
          key: "assetCode",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "设备编号",
          key: "deviceNo",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "设备类型",
          key: "deviceCategory",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "所在位置",
          key: "installPositionName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "操作",
          slot: "action",
          fixed: "right",
          minWidth: 180,
          align: "center"
        }
      ],
      columns2: [
        {
          key: "selection",
          type: "selection",
          width: 60,
          align: "center"
        },
        // {
        //   title: "优先级",
        //   key: "sort",
        //   slot: "priority",
        //   minWidth: 100,
        //   align: "center",
        //   resizable: true,
        //   tooltip: true,
        //   render: (h, params) => {
        //     return h("div", [
        //       h("InputNumber", {
        //         props: {
        //           min: 0,
        //           max: 9999,
        //           value: params.row.priority || ""
        //         },
        //         on: {
        //           // 编辑数量的时候,触发的事件
        //           "on-change": e => {
        //             params.row.priority = e;
        //             this.dataArr2[params.index] = params.row;
        //             this.delIds2.forEach((v, index) => {
        //               // 先循环选中的值,找到id,与所有data里的id进行比对
        //               if (v.id == params.row.id) {
        //                 this.delIds2.splice(index, 1, params.row);
        //               }
        //             });
        //             //                    this.updateData(this.data) // 不要这步，改变的时候触发一下改变数据时事件,这样只要编辑了就会获取里面的值
        //           }
        //         }
        //       })
        //     ]);
        //   }
        // },
        {
          title: "设备名称",
          key: "deviceName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "资产编号",
          key: "assetCode",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "设备编号",
          key: "deviceNo",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "设备类型",
          key: "deviceCategory",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "所在位置",
          key: "installPositionName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        }
      ],
      columns3: [
      {
          title: '序号',
          width: 80,
          align: 'center',
          render: (h, params) => {
            return h('span', params.index + (this.pageNum - 1) * this.pageSize + 1);
          },
        },
        {
          title: "资产编号",
          key: "assetCode",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装编号",
          key: "assetCode",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装名称",
          key: "equipName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装类型",
          key: "moldModel",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装产品型号",
          key: "moldModel",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装状态",
          key: "moldState",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "生产次数",
          key: "productionFrequency",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
					title: '是否启用',
					key: 'isEnabled',
					minWidth: 150,
					align: 'center',
					resizable: true,
					sortable: true,
					render: (h, params) => {
						return h('div', params.row.isEnabled == 1 ? '启用' : '禁用');
					},
				},
        {
          title: "二级保养次数",
          key: "secondaryFrequency",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "二级实际保养次数",
          key: "secondaryActualFrequency",
          minWidth: 180,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "三级实际保养次数",
          key: "thirdLevelFrequency",
          minWidth: 180,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装等级",
          key: "moldGrade",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "评分",
          key: "score",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "日额定",
          key: "dayQuota",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工时额定（PCS/H）",
          key: "hourQuota",
          minWidth: 180,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "理论节拍（s）",
          key: "moldingCycle",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装寿命",
          key: "moldLife",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工装剩余寿命",
          key: "moldResidueLife",
          minWidth: 150,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "功能位置",
          key: "functionalLocation",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "库区",
          key: "",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "库位",
          key: "",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "利用率",
          key: "useRate",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "创建人",
          key: "createName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "创建时间",
          key: "createTime",
          minWidth: 200,
          align: "center",
          resizable: true,
          tooltip: true
        },
      ],
      moldCode: "",
      id: "",

      loading: false,
      loading1: false,
      loading2: false,
      // 一级二级弹窗显示
      create: false,
      createLink: false,
      //三级搜索参数
      searchParams: {},
      searchParams1: {},
      searchParams2: {},
      //一级页面分页参数
      pageNum: 1,
      pageSize: 10,
      total: 0,
      //二级页面分页参数
      pageNum1: 1,
      pageSize1: 10,
      total1: 0,
      //三级页面分页参数
      pageNum2: 1,
      pageSize2: 10,
      total2: 0,
      // 详情
      pageNum3: 1,
      pageSize3: 10,
      total3: 0,
      //一级table列表数据
      dataArr: [],
      dataArr1: [],
      dataArr2: [],
      dataArr3:[],
      backupList: [],
      shelfList: [],
      locationList: [],
      allCheck: false,
      bomDetail: false,
      delFaultCodeShowF: false, //是否显示删除弹窗
      pageSizeOption: [10, 20, 30, 40],
      delIds: [],
      delIds1: [],
      delIds2: [],
      selection: [],
      createByOptions: []
    };
  },
  mounted() {
    this.getTableColumnsWidth(this.columns);
    this.searchList();
  },
  methods: {
    showDetail(row){
      this.delIds3 = [];
      this.id = row.id;
      this.getDetail();
    },
    getDetail(){
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        moldId: this.id
      };
      mdDetail(params).then(res => {
        if (res.code === 200) {
          this.dataArr3 = res.data.records;
          this.total3 = res.data.total;
          this.bomDetail = true
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    },
    getSearch(arg) {
      this.searchParams = JSON.parse(JSON.stringify(arg[0]));
      const { functionalLocationString } = this.searchParams;
      if (functionalLocationString && functionalLocationString.length != 0) {
        this.searchParams.functionalLocationString = functionalLocationString.at(-1);
      } else delete this.searchParams.functionalLocationString
      this.changeNum();
    },
    getSearch1(arg) {
      this.searchParams1 = JSON.parse(JSON.stringify(arg[0]));
      const { functionalLocationString } = this.searchParams1;
      if (functionalLocationString && functionalLocationString.length != 0) {
        this.searchParams1.functionalLocationString = functionalLocationString.at(-1);
      } else delete this.searchParams1.functionalLocationString
      // this.searchParams1 = JSON.parse(JSON.stringify(arg[0]));
      // const data = this.searchParams1.installPosition;
      // if (data && data.length > 1) {
      //   this.searchParams1.installPosition = [data[data.length - 1]];
      // }
      this.delIds1 = [];
      this.changeNum1();
    },
    getSearch2(arg) {
      this.searchParams2 = JSON.parse(JSON.stringify(arg[0]));
      const { functionalLocationString } = this.searchParams2;
      if (functionalLocationString && functionalLocationString.length != 0) {
        this.searchParams2.functionalLocationString = functionalLocationString.at(-1);
      } else delete this.searchParams2.functionalLocationString
      // this.searchParams2 = JSON.parse(JSON.stringify(arg[0]));
      // const data = this.searchParams2.installPosition;
      // if (data && data.length > 1) {
      //   this.searchParams2.installPosition = [data[data.length - 1]];
      // }
      this.delIds2 = [];
      this.changeNum2();
    },
    getDeviceList(row) {
      this.delIds = [];
      this.delIds1 = [];
      this.delIds2 = [];
      this.moldCode = row.moldCode;
      this.id = row.id;
      this.$refs.search1.reset();
      this.searchList1();
    },
    reset() {
      this.searchParams = {};
      this.changeNum();
    },
    //分页
    changeNum() {
      this.pageNum = 1;
      this.searchList();
    },
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.searchList();
    },
    changePageNum(val) {
      this.pageNum = val;
      this.searchList();
    },
    // 2
    changeNum1() {
      this.pageNum1 = 1;
      this.searchList1();
    },
    changePageSize1(pageSize) {
      this.pageSize1 = pageSize;
      this.searchList1();
    },
    changePageNum1(val) {
      this.pageNum1 = val;
      this.searchList1();
    },
    // 3
    changeNum2() {
      this.pageNum2 = 1;
      this.searchList2();
    },
    changePageSize2(pageSize) {
      this.pageSize2 = pageSize;
      this.searchList2();
    },
    changePageNum2(val) {
      this.pageNum2 = val;
      this.searchList2();
    },
    changeNum3() {
      this.pageNum3 = 1;
      this.getDetail()
    },
    changePageSize3(pageSize) {
      this.pageSize3 = pageSize;
      this.getDetail()
    },
    changePageNum3(val) {
      this.pageNum3 = val;
      this.getDetail()
    },

    //查询列表
    searchList() {
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        devicesNumber: this.searchParams.devicesNumber || "2"
      };
      for (let key in this.searchParams) {
        if (this.searchParams[key]) {
          this.$set(params, key, this.searchParams[key]);
        }
      }
      searchApi(params).then(res => {
        if (res.code === 200) {
          this.dataArr = res.data.records;
          this.total = res.data.total;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    },
    //查询列表
    searchList1() {
      let params = {
        pageNum: this.pageNum1,
        pageSize: this.pageSize1,
        moldId: this.id
      };
      for (let key in this.searchParams1) {
        if (this.searchParams1[key]) {
          this.$set(params, key, this.searchParams1[key]);
        }
      }
      getLinkList(params).then(res => {
        if (res.code === 200) {
          this.dataArr1 = res.data.records;
          this.total1 = res.data.total;
          this.create = true;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    },
    getNoList() {
      this.$refs.search2.reset();
    },
    //查询列表
    searchList2() {
      let params = {
        pageNum: this.pageNum2,
        pageSize: this.pageSize2,
        moldId: this.id
      };
      for (let key in this.searchParams2) {
        if (this.searchParams2[key]) {
          this.$set(params, key, this.searchParams2[key]);
        }
      }
      getDeviceNoList(params).then(res => {
        if (res.code === 200) {
          this.dataArr2 = res.data.records;
          this.total2 = res.data.total;
          this.createLink = true;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    },
    //勾选列表
    onSelectChange(selection) {
      let myArray = [];
      selection.map((item, index) => {
        myArray.push(item.id);
      });
      this.delIds = myArray;
      if (selection.length > 0) {
        this.allCheck = true;
      } else {
        this.allCheck = false;
      }
    },
    //勾选列表
    onSelectChange1(selection) {
      let myArray = [];
      selection.map((item, index) => {
        myArray.push(item.id);
      });
      this.delIds1 = myArray;
      if (selection.length > 0) {
        this.allCheck = true;
      } else {
        this.allCheck = false;
      }
    }, //勾选列表
    onSelectChange2(selection) {
      this.delIds2 = selection;
    },
    //批量删除
    delRowBetch() {
      if (this.delIds1.length == 0) {
        this.$Message.warning({
          content: `${this.$t("common.deleteItems")}`,
          duration: 6,
          closable: true
        });
        return;
      } else {
        this.delFaultCodeShowF = true;
      }
    },
    //删除
    delRow(row) {
      //点击展示提示删除弹窗
      this.delFaultCodeShowF = true;
      this.delIds1 = [];
      this.delIds1.push(row.id);
    },
    deleteOk() {
      this.loading = true;
      let params = { deviceIdList: this.delIds1, moldId: this.id };
      // let params = this.delIds1;
      deleteApi(params).then(res => {
        this.loading = false;
        if (res.code === 200) {
          this.changeNum1();
          this.searchList();
          this.$Message.success("删除成功");
          this.$refs.selection.selectAll(false);
          this.delIds1 = [];
          this.delFaultCodeShowF = false;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    },
    linkEq() {
      // let deviceIdList = this.delIds2.map(item => ({
      //   deviceId: item.id,
      //   priority: item.priority
      // }));
      let deviceIdList = this.delIds2.map(item => item.id);
      if (deviceIdList.length == 0) {
        this.$Message.error("请选择需要关联的设备");
        return;
      }
      this.loading = true;

      let params = { deviceIdList, moldId: this.id };
      devicesAssociated(params).then(res => {
        this.loading = false;
        if (res.code === 200) {
          this.$Message.success("关联成功");
          this.$refs.selection.selectAll(false);
          this.createLink = false;
          this.changeNum();
          this.changeNum1();
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.ivu-input-number {
  width: -webkit-fill-available;
}

.btn-box {
  padding: 8px 5px !important;
}
</style>
